package swingSection;

import java.awt.BorderLayout;
import java.awt.Rectangle;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JFrame;
import javax.swing.JTextField;

import org.hibernate.engine.transaction.Isolater.JtaDelegate;

public class EditDialog extends JDialog {

	private static final long serialVersionUID = 1L;
	private JPanel jContentPane1 = new JPanel();
	private JLabel nameLabel = new JLabel();
	private JTextField nameText = new JTextField();
	private JLabel newNameLabel = new JLabel();
	private JTextField newNameText = new JTextField();
	private JLabel newPassLabel = new JLabel();
	private JTextField newPassText = new JTextField();
	private JButton okButton = new JButton();
	private JButton cancelButton = new JButton();
	private int result=1;

	public EditDialog() {
		super();
		this.getRootPane().setDefaultButton(okButton);
		this.setLayout(null);
		this.setDefaultCloseOperation(JDialog.HIDE_ON_CLOSE);
		this.setModal(true);
		this.setBounds(new Rectangle(50, 50, 140, 330));
		jContentPane1.setBounds(new Rectangle(50, 50, 140, 330));
		this.add(jContentPane1);
		this.setTitle("Edit User");
		nameLabel.setBounds(new Rectangle(10, 10, 130, 25));
		nameLabel.setText("Username:");
		this.add(nameLabel);
		nameText.setBounds(new Rectangle(10, 45, 100, 25));
		this.add(nameText);
		newNameLabel.setBounds(new Rectangle(10, 80, 130, 25));
		newNameLabel.setText("New username:");
		this.add(newNameLabel);
		newNameText.setBounds(new Rectangle(10, 115, 100, 25));
		this.add(newNameText);
		newPassLabel.setBounds(new Rectangle(10, 150, 130, 25));
		newPassLabel.setText("New password:");
		this.add(newPassLabel);
		newPassText.setBounds(new Rectangle(10, 185, 100, 25));
		this.add(newPassText);
		okButton.setBounds(new Rectangle(10, 220, 100, 25));
		okButton.setText("OK");
		okButton.addActionListener(new ActionListener() {
			@Override
			public void actionPerformed(ActionEvent e) {
				result = 0;
				setVisible(false);
			}

		});
		this.add(okButton);
		cancelButton.setBounds(new Rectangle(10, 255, 100, 25));
		cancelButton.setText("Cancel");
		cancelButton.addActionListener(new ActionListener() {

			@Override
			public void actionPerformed(ActionEvent e) {
				result = 1;
				setVisible(false);
			}

		});
		this.add(cancelButton);
	}

	public int showDialog() {
		nameText.setText("");
		newNameText.setText("");
		newPassText.setText("");
		this.setVisible(true);
		return result;
	}

	public String getUserName() {
		return nameText.getText();
	}

	public String getNewUserName() {
		return newNameText.getText();
	}

	public String getNewPassword() {
		return newPassText.getText();
	}

	public int getResult() {
		return result;
	}
}
